package com.ecust.ml.cardriving.model;

import java.util.HashMap;
import java.util.Map;

public class Highway {

	public static final int OFFROAD_LEFT	= 1;
	public static final int LANE_LEFT		= 2;
	public static final int LANE_MIDDLE		= 3;
	public static final int LANE_RIGHT		= 4;
	public static final int OFFROAD_RIGHT	= 5;
	
	/**
	 * 高速路上的道路对象
	 * <道路编号, 道路对象>
	 */
	private Map<Integer, Road> roads = new HashMap<Integer, Road>();
	
	public Highway() {
		roads.put(OFFROAD_LEFT, new Road(OFFROAD_LEFT));
		roads.put(LANE_LEFT, new Road(LANE_LEFT));
		roads.put(LANE_MIDDLE, new Road(LANE_MIDDLE));
		roads.put(LANE_RIGHT, new Road(LANE_RIGHT));
		roads.put(OFFROAD_RIGHT, new Road(OFFROAD_RIGHT));
	}
	
	/**
	 * 检测某车道是否有冲突
	 * @param lane 车道编号
	 * @return
	 */
	public Collision findCollision(int lane) {
		if(roads.containsKey(lane)) {
			return roads.get(lane).findCollision();
		} else {
			return null;
		}
	}

	public Map<Integer, Road> getRoads() {
		return roads;
	}

	public void setRoads(Map<Integer, Road> roads) {
		this.roads = roads;
	}
	
}
